﻿using System;
using System.Configuration;

using BizElements.Web;
using BizElements.Web.UI;

namespace BizElements.Web.UI
{
    public partial class ToolbarFrm : System.Web.UI.Page
    {
        /// <summary>WebLayout setting in config file.</summary>
        static readonly string WebLayout = ConfigurationManager.AppSettings["WebLayout"];

        /// <summary>Tries to initialize Page.UICulture to match culture defined in UserSession.UiCulture.</summary>
        protected override void InitializeCulture()
        {
            if (UserSession.UiCulture != null)
                this.UICulture = UserSession.UiCulture.Name;
        }

        /// <summary>Sets target frame that matches WebLayout configuration.</summary>
        protected void Page_Init(object sender, EventArgs e)
        {
            if (WebLayout == "frameset")
                this.uiToolbar.TargetFrame = "currentForm";
            else if (WebLayout == "iframe")
                this.uiToolbar.TargetFrame = "_parent";
            else
                this.uiToolbar.TargetFrame = null;
        }
    }
}
